﻿using System.Collections.Generic;
using System.ServiceModel;
using Metro.Kashikoi.Common.Entity;
using Metro.Kashikoi.Common.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF;
using Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

namespace Metro.Kashikoi.ServiceContract.Item
{
    /// <summary>
    /// This interface provides method to manage the category.
    /// </summary>
    [ServiceContractAttribute]
    [ExceptionShielding]
    public interface ICategoryService
    {
        /// <summary>
        /// Creates the category.
        /// </summary>
        /// <param name="category">The category to be created.</param>
        /// <returns>The newly created category.</returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        ColorCategory CreateCategory(ColorCategory category);

        /// <summary>
        /// Updates the category.
        /// </summary>
        /// <param name="category">The category to be updated.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void UpdateCategory(ColorCategory category);

        /// <summary>
        /// Deletes the category.
        /// </summary>
        /// <param name="categoryId">The category id.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void DeleteCategory(
            [RangeValidator(0, RangeBoundaryType.Exclusive, int.MaxValue, RangeBoundaryType.Exclusive)]
            int categoryId);

        /// <summary>
        /// Gets the category by id.
        /// </summary>
        /// <param name="id">The category id.</param>
        /// <returns>The category with specific id.</returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        ColorCategory GetCategory(
            [RangeValidator(0, RangeBoundaryType.Exclusive, int.MaxValue, RangeBoundaryType.Exclusive)]
            int id);

        /// <summary>
        /// Gets all the categories.
        /// </summary>
        /// <returns>A list of the category.</returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        IList<ColorCategory> GetAllCategories();
    }
}
